package com.example.changtest.ui.widget.glance


import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.glance.Button
import androidx.glance.GlanceModifier
import androidx.glance.Image
import androidx.glance.ImageProvider
import androidx.glance.action.actionStartActivity
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.background
import androidx.glance.appwidget.cornerRadius
import androidx.glance.appwidget.lazy.LazyColumn
import androidx.glance.layout.*
import androidx.glance.text.FontWeight
import androidx.glance.text.Text
import androidx.glance.text.TextStyle
import com.example.changtest.R
import com.example.changtest.ui.H5Activity

/**
 * @Description:
 * @author: zcs
 * @email: 1059737741@qq.com
 * create at 2022/2/18 18:11
 */
class FirstGlanceWidget : GlanceAppWidget(){
    @Composable
    override fun Content() {
        Column(modifier = GlanceModifier
            .fillMaxSize()
            .background(day = Color.Red, night = Color.Blue)
            .cornerRadius(10.dp)
            .padding(8.dp)
        ) {
            Text(
                text = "First Glance widget",
                modifier = GlanceModifier.fillMaxWidth(),
                style = TextStyle(fontWeight = FontWeight.Bold),
            )

            Spacer(modifier = GlanceModifier.height(5.dp))
            Row {
                LazyColumn(modifier = GlanceModifier.width(150.dp)) {
                    items(4) {
                        Text(text = "哈哈哈")
                    }
                }
                Image(
                    provider = ImageProvider(R.mipmap.record_wait),
                    modifier = GlanceModifier.height(50.dp),
                    contentDescription = ""
                )
            }

            Row {
                Text(text = "横着1")
                Text(text = "横着2 ", modifier = GlanceModifier.padding(10.dp))
            }

            Button(text = "Glance按钮", onClick = actionStartActivity(H5Activity::class.java))

        }

    }
}